'''
from http://sciyoshi.com/blog/2008/jul/10/dynamic-django-settings-context-processor/
add these context processors to you settings.py

all variable can be get from the django setting.py

TEMPLATE_CONTEXT_PROCESSORS = (
    # ....
    'utils.context_processors.settings.GOOGLEMAPS_KEY',
    'utils.context_processors.settings.TEMPLATE_DEBUG',
    'utils.context_processors.settings.MAXMIND_URL',
)
'''
import sys
from django.conf import settings as django_settings


class SettingsProcessor(object):

    def __getattr__(self, attr):
        if attr == '__file__':
            # autoreload support in dev server
            return __file__
        else:
            return lambda request: {attr: getattr(django_settings, attr)}


'''
Here's a nice way of easily passing only certain settings variables to the template. Because of the way Django looks up context processors, we need a little hack with sys.modules.
'''
sys.modules[__name__ + '.settings'] = SettingsProcessor()
